import { User } from '../../../core/auth/user.service';
import { ConfigService } from '../../../core/common/config.service';
import { BaseService } from '../../../core/service/base.service';
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs';
@Injectable()
export class CustomerService extends BaseService {
  constructor(protected http: Http, protected config: ConfigService) {
    super(http, config);
  }
  public getCustomers(pageNum: number, pageSize: number): Observable<any> {
    const url = 'service=QueryInfoService&method=getChannelCustByUser';
    return super.query(url, null, pageNum, pageSize);
  }
  public getNodesByCust(custId: string): Observable<any> {
    const url = 'service=QueryInfoService&method=getNodesByCust';
    return super.query(url, { custId: custId, type: '1' }, null, null);
  }
  public isExistsAccount(email: string): Observable<boolean> {
    const url = 'service=QueryInfoService&method=isExistsAccount';
    return super.query(url, { contactEmail: email }, null, null).map((d: any) => {
      return d.flag;
    });
  }
  public getAdjustRecords(start_date: string, end_date: string, pageNum: number, pageSize: number): Observable<any> {
    const url = 'service=ChnlAdjustBillService&method=getChnlAdjustBillInfo';
    return super.query(url, {'start_date' : start_date, 'end_date': end_date}, pageNum, pageSize);
  }

  public getMyorders(custName: string, orderState: string, pageNum: number, pageSize: number): Observable<any> {
    const url = 'service=OrderService&method=getMyOrder';
    return super.query(url, {'custName': custName, 'orderState': orderState}, pageNum, pageSize);
  }
  public getNodesByOrder(orderId: string): Observable<any> {
    const url = 'service=QueryInfoService&method=getNodesByOrder';
    return super.query(url, { orderId: orderId, type: '1' }, null, null);
  }
}
